package com.xiaochong.tir.api.controller.walian;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.xiaochong.service.common.config.redis.RedisServer;
import com.xiaochong.tir.common.util.ApiResultCodeUtils;
import com.xiaochong.tir.common.util.RedisKeysUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xiaochong.tir.api.service.TokenIndexRankService;
import com.xiaochong.tir.api.service.walian.TokenIndexService;
import com.xiaochong.tir.api.util.ApiVersion;
import com.xiaochong.tir.common.data.vo.ApiMarketAnalysisTotalResult;
import com.xiaochong.tir.common.data.vo.ApiResultVo;
import com.xiaochong.tir.common.data.vo.walian.WalianDiagnosis;

/**
 * 挖链的接口
 * @author qzw
 * 2018年7月2日 下午12:01:53
 * @description 
 **/
@Api(value="挖链接口")
@RestController
@RequestMapping(ApiVersion.API_V1_PREFIX+"/tir/walian/index")
public class TokenIndexController {
	
	@Autowired
    private TokenIndexRankService tokenIndexRankService;

    @Autowired
    private RedisServer redisServer;

	@ApiOperation(value = "大盘强弱分析-大盘强度", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/grailStrength")
    public ApiResultVo<ApiMarketAnalysisTotalResult> getGrailStrength(){
        return tokenIndexRankService.getMarketAnalysisTotalResult();
    }
	
	@ApiOperation(value = "货币诊断-曲线图和评语", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/currencyAndScore")
    public ApiResultVo<List<WalianDiagnosis>> getCurrencyAndScore(){
        String str = redisServer.get(RedisKeysUtils.WLAPI_CURRENCY_DIAGNOSIS_GRAPHS_COMMENTS);
        List<WalianDiagnosis> list =JSON.parseArray(str,WalianDiagnosis.class) ;
        ApiResultVo<List<WalianDiagnosis>> apiWdList = new ApiResultVo<List<WalianDiagnosis>>();
        apiWdList.setCode(ApiResultCodeUtils.BASE_SUCCESS.getCode());
        apiWdList.setMessage(ApiResultCodeUtils.BASE_SUCCESS.getMsg());
        apiWdList.setData(list);
        return apiWdList;
    }
}
